/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package co.edu.uniminuto.Videominuto.entities;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author JULIAN
 */
@Entity
@Table(name = "idioma")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Idioma.findAll", query = "SELECT i FROM Idioma i"),
    @NamedQuery(name = "Idioma.findByIdLenguaje", query = "SELECT i FROM Idioma i WHERE i.idLenguaje = :idLenguaje"),
    @NamedQuery(name = "Idioma.findByLenguaje", query = "SELECT i FROM Idioma i WHERE i.lenguaje = :lenguaje")})
public class Idioma implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id_lenguaje")
    private Integer idLenguaje;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 10)
    @Column(name = "lenguaje")
    private String lenguaje;
    @ManyToMany(mappedBy = "idiomaList")
    private List<Video> videoList;
    @ManyToMany(mappedBy = "idiomaList1")
    private List<Video> videoList1;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idIdiomaOriginal")
    private List<Video> videoList2;

    public Idioma() {
    }

    public Idioma(Integer idLenguaje) {
        this.idLenguaje = idLenguaje;
    }

    public Idioma(Integer idLenguaje, String lenguaje) {
        this.idLenguaje = idLenguaje;
        this.lenguaje = lenguaje;
    }

    public Integer getIdLenguaje() {
        return idLenguaje;
    }

    public void setIdLenguaje(Integer idLenguaje) {
        this.idLenguaje = idLenguaje;
    }

    public String getLenguaje() {
        return lenguaje;
    }

    public void setLenguaje(String lenguaje) {
        this.lenguaje = lenguaje;
    }

    @XmlTransient
    public List<Video> getVideoList() {
        return videoList;
    }

    public void setVideoList(List<Video> videoList) {
        this.videoList = videoList;
    }

    @XmlTransient
    public List<Video> getVideoList1() {
        return videoList1;
    }

    public void setVideoList1(List<Video> videoList1) {
        this.videoList1 = videoList1;
    }

    @XmlTransient
    public List<Video> getVideoList2() {
        return videoList2;
    }

    public void setVideoList2(List<Video> videoList2) {
        this.videoList2 = videoList2;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idLenguaje != null ? idLenguaje.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Idioma)) {
            return false;
        }
        Idioma other = (Idioma) object;
        if ((this.idLenguaje == null && other.idLenguaje != null) || (this.idLenguaje != null && !this.idLenguaje.equals(other.idLenguaje))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "co.edu.uniminuto.Videominuto.entities.Idioma[ idLenguaje=" + idLenguaje + " ]";
    }
    
}
